package com.ygqh.baby.model;

import com.ygqh.baby.ao.CheckStatus;
import com.ygqh.baby.ao.Message;
import com.ygqh.baby.po.YgUser;
import com.ygqh.baby.po.YgVoteWork;
import org.apache.commons.lang.StringUtils;

import java.util.Date;

/**
 * @author: sunshuo
 * @date: 2018/12/25 14:12
 */
public class CommitVoteWorkReq extends BaseRequestParam {

	private String babyName;

	private String babyImageUrl;

	private String description;

	private YgVote voteInfo;

	private YgUser currentUser;

	public String getBabyName() {
		return babyName;
	}

	public void setBabyName(String babyName) {
		this.babyName = babyName;
	}

	public String getBabyImageUrl() {
		return babyImageUrl;
	}

	public void setBabyImageUrl(String babyImageUrl) {
		this.babyImageUrl = babyImageUrl;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Message validateParam() {
		if (StringUtils.isBlank(this.babyName)) {
			return Message.error("宝宝昵称不能为空", null);
		}
		if (StringUtils.isBlank(this.babyImageUrl)) {
			return Message.error("作品照片不能为空", null);
		}
		return Message.success(null);
	}

	public YgVote getVoteInfo() {
		return voteInfo;
	}

	public CommitVoteWorkReq setVoteInfo(YgVote voteInfo) {
		this.voteInfo = voteInfo;
		return this;
	}

	public YgUser getCurrentUser() {
		return currentUser;
	}

	public CommitVoteWorkReq setCurrentUser(YgUser currentUser) {
		this.currentUser = currentUser;
		return this;
	}

	public YgVoteWork build() {
		YgVoteWork record = new YgVoteWork();
		record.setVoteBatchCode(voteInfo.getVoteBatchCode());
		record.setUserId(currentUser.getId());
		record.setUserName(currentUser.getUserName());
		record.setBabyName(babyName);
		record.setBabyImageUrl(babyImageUrl);
		record.setDescription(description);
		record.setCreateTime(new Date());
		record.setCreateBy(currentUser.getUserName());
		record.setUpdateTime(record.getCreateTime());
		record.setUpdateBy(record.getCreateBy());
		return record;
	}
}
